﻿<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		

		<title>密码修改</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<style type="text/css">

a:link    {font-size: 12px; color: #000000; text-decoration: none; border:none;}
a:visited {font-size: 12px; color: #000000; text-decoration: none; border:none;}
a:hover   {font-size: 12px; color: #000000; text-decoration: underline; border:none;}
a:active  {font-size: 12px; color: #000000; text-decoration: none; border:none;}

.login { width: 50px; height: 22px; margin-left: 0px;color:#000000; cursor: pointer; border: none; background: transparent url('<%=basePath%>images/button2.gif') no-repeat scroll left top; }
</style>
		<script language=javascript>  
			//判断输入密码的类型  
			//测试某个字符是属于哪一类.  
			function CharMode(iN){  
			if (iN>=48 && iN <=57) //数字  
			return 1;  
			if (iN>=65 && iN <=90) //大写  
			return 2;  
			if (iN>=97 && iN <=122) //小写  
			return 4;  
			else  
			return 8;   //特殊字符  
			}  
			//bitTotal函数  
			//计算出当前密码当中一共有多少种模式  
			function bitTotal(num){  
			modes=0;  
			for (i=0;i<4;i++){  
			if (num & 1) modes++;  
			num>>>=1;  
			}  
			return modes;  
			}  
			//返回强度级别  
			function checkStrong(sPW){  
			if (sPW.length<8)  
			return 0; //密码太短  
			Modes=0;  
			for (i=0;i<sPW.length;i++){  
			//测试每一个字符的类别并统计一共有多少种模式.  
			Modes|=CharMode(sPW.charCodeAt(i));  
			}  
			return bitTotal(Modes);  
			}  
			var S_level=0;
			//显示颜色  
			function pwStrength(pwd){  
			O_color="#eeeeee";  
			L_color="#FF0000";  
			M_color="#FF9900";  
			H_color="#33CC00";  
			if (pwd==null||pwd==''){  
			Lcolor=Mcolor=Hcolor=O_color;  
			}  
			else{  
			S_level=checkStrong(pwd);  
			switch(S_level) {  
			case 0:  
			Lcolor=Mcolor=Hcolor=O_color;  
			case 1:  
			Lcolor=L_color;  
			Mcolor=Hcolor=O_color;  
			break;  
			case 2:  
			Lcolor=Mcolor=M_color;  
			Hcolor=O_color;  
			break;  
			default:  
			Lcolor=Mcolor=Hcolor=H_color;  
			}  
			}  
			document.getElementById("strength_L").style.background=Lcolor;  
			document.getElementById("strength_M").style.background=Mcolor;  
			document.getElementById("strength_H").style.background=Hcolor;  
			return;  
			}  
			
			function sub(){
				var newPwd=document.getElementById("newPwd").value;
				var newPwd2=document.getElementById("newPwd2").value;
//				if(newPwd.length<7){
//					alert("新密码不得小于8位！");
//				}
				if(S_level<2){
					alert("密码强度不够！");
				}else{
					if(newPwd != newPwd2){
						alert("两次输入密码不一致！");
					}else{
						document.changePwd.submit();
					}
				}
			}
			function exit(){
				document.getElementById("newPwd").value=""
				document.getElementById("newPwd2").value=""
				document.getElementById("oldPwd").value=""
			}
			
			
</script>

	</head>

	<body >

		<%
		//	String message=(String)request.getParameter("message");	
        //    if(message!=null){
        //        String str=new String(message.getBytes("8859_1"),"GB2312"); 
        //        out.println(str);
        //    }
        	String message=(String)request.getAttribute("message");
        	String html="<font color='red' style='font-size: 12px'>"+message+"</font><br>";
        	if(message!=null){
        		out.println(html);
        	}
		 %>
		<form name="changePwd" method="post" action="<%=path%>/user/pwdChange.do">
			<table width="100%" height="90" align="center" style="font-size: 12px">
				<tr>
					<td width="80">
				  <div>旧密码：</div></td>
					<td>
						<div align="left">
						  <input type="password" name="oldPwd" id="oldPwd" width="200">					

				  </div></td>
				</tr>
				<tr>
					<td colspan="2">
						<div align="left">注意：新密码长度不得小于8位，且至少使用2种不同类型字符（

如：大小写字母加数字）！					</div></td>
				</tr>
				<tr>
					<td width="80">
				  <div>新密码：</div></td>
					<td>
						<div align="left">
						  <input id="newPwd" type="password" name="newPwd"
							onKeyUp=pwStrength(this.value) onBlur=pwStrength(this.value)>		

			
					  </div></td>
				</tr>
				<tr>
					<td width="80">
				  <div >密码强度：	</div></td>
					<td>
						<div align="left">
						  <table width="145" border="1" cellspacing="0" cellpadding="1"
							bordercolor="#eeeeee" height="22" style='display: inline;font-size: 

12px'>
						    <tr align="center" bgcolor="#f5f5f5">
						      <td width="33%" id="strength_L">
						        弱								

</td>
							    <td width="33%" id="strength_M">
								    中								

</td>
							    <td width="33%" id="strength_H">
								    强								

</td>
						    </tr>
					      </table>
				  </div></td>
				</tr>
				<tr>
					<td width="80">
				  <div>重复新密码：</div></td>
					<td>
						<div align="left">
						  <input id="newPwd2" type="password" name="newPwd2">				
					  </div></td>
				</tr>
				<tr>
					<td colspan="2">
						<div align="left">
						<a href="javaScript:sub();" ><input type="button" name="enter" value="修改" class="login" onClick="sub()"/></a>
						<a href="javaScript:exit();" ><input type="button" name="enter" value="重置" class="login" onClick="exit()"/></a>
					    <a href="<%=basePath%>help/mmxg.jsp" target="_blank">帮助

</a></div></td>
				</tr>
		  </table>
		</form>
	</body>
</html>
